﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="desktop.aspx.cs" Inherits="FL.Web.BackEnd.BasePage" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>主页面模板</title>
    <script src="../../SFramework/boot.js"></script>
    <script src="../../Scripts/app/edit.common.js"></script>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <link href="../demo.css" rel="stylesheet" type="text/css" />
    <style>
    span.mini-tools-add
    {
        width:16px;height:16px;
        background:url(add.gif) no-repeat;
    }
    span.mini-tools-edit
    {
        width:16px;height:16px;
        background:url(edit.gif) no-repeat;
    }    
    span.mini-tools-remove
    {
        width:16px;height:16px;
        background:url(remove.gif) no-repeat;
    }
        #divRight > div {
            padding-left:0px;
        }       
    </style>    
</head>
<body>
    <form id="form1" runat="server">
        <div class="row-fluid"></div>
        <div class="row-fluid">
            <div style="width:79.5%;float:left;" id="divLeft">
                
            </div>
            <div style="width:20%;float:right;padding-left:0px" id="divRight">
            </div>
        </div>
    </form>
</body>
<script src="../../Scripts/common/jquery.data.js"></script>
</html>
<script type="text/javascript">
    mini.parse();
    //基于 jquery.data.js 取数据
    var data = fnGetData("v_sys_user_desktop", "user_id='@UserID'", "sort");
    var DataMain = data.data;
    //html 模板定义
    var _template = '<div class="mini-panel" title="[title]" style="height:[height];width:100%;margin-top:10px;"' +
    'buttons="close collapse" onbuttonclick="onbuttonclick">' +
    '<div style="height:100%;width:100%;" id="[id]">' +
    '<div style="height:100%;width:100%;">[content]</div>' +
    '</div>' +
    '</div>';
    var _datatemp = "";
    for (var i = 0; i < DataMain.length; i++) {
        //0,内容ajax加载,1,iframe 页面加载
        var html = _template.replace("[title]", DataMain[i].title).replace("[id]", DataMain[i].id).replace("[height]", DataMain[i].height).replace("[content]", _datatemp);
        html = html.replace("[id]", DataMain[i].id);
        if (DataMain[i].area == "L") {
            $("#divLeft").append(html);
        }
        else {
            $("#divRight").append(html);
        }

        if (DataMain[i].content_type == "0") {
            getUrlData2(DataMain[i].data_url, $("#" + DataMain[i].id));
        }
        else {
            _datatemp = "<iframe scrolling=\"auto\" frameborder=\"0\"  src=\"" + DataMain[i].data_url + "\" style=\"width:100%;height:" + DataMain[i].height + "px; margin:0px;\"></iframe>";
            $("#" + DataMain[i].id).html(_datatemp);
        }
    }
    //根据URL返回URL HTML内容
    function getUrlData2(url, targetEml) {
        if (url.indexOf("?") > 0) {
            url += "&r=" + Math.random();
        }
        else {
            url += "?r=" + Math.random();
        }
        $.ajaxSetup({
            error: function (x, e) {
                var myError = x.responseText;
                targetEml.html(myError);
            }
        });

        $.getJSON(url, function (_html) {
            targetEml.html(_html);
        });
    }

    function onbuttonclick(e) {
        if (e.name == "add") {
            alert("add");
        }
        if (e.name == "edit") {
            alert("edit");
        }
        if (e.name == "remove") {
            alert("remove");
        }
    }

    //var panel = mini.get("p1");
    //panel.setButtons([{ html: '<a href="#" style="position:relative;top:-4px;">详细</a>' }]);
</script>
